import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_html/shims/dart_ui_real.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:video_player/video_player.dart';
import 'package:yp/Xwidgets/button_widget.dart';
import 'package:yp/config/index.dart';
import 'package:yp/config/style.dart';
import 'package:yp/pages/main/logic.dart';
import 'package:yp/pages/main/state.dart';
import 'package:yp/pages/order_create/widgets/specifications_widget.dart';
import 'package:yp/router.dart';
import 'package:yp/services/api.dart';
import 'package:yp/utils/util.dart';
import 'package:yp/utils/videoplayer/video_player_plus.dart';
import 'package:yp/widgets/index.dart';
import 'package:yp/widgets/shop.dart';

import './trolley_logic.dart';
import '../../helper.dart';

import 'package:yp/pages/address_selector/address_model.dart';

class TrolleyPage extends StatefulWidget {
  @override
  _TrolleyPageState createState() => _TrolleyPageState();
}

class _TrolleyPageState extends State<TrolleyPage>
    with SingleTickerProviderStateMixin {
  final logic = Get.put(TrolleyLogic());
  final state = Get.find<TrolleyLogic>().state;

  void _plus(cartId, cheaced, sum) {
    sum++;
    logic.cartItemEdit(cartId, cheaced, sum);
    // logic.cartGoodsData();
    // logic.update();
    // controller.text = _sum.toString();
    // setState(() {});
  }

  guige(info) {
    logic.goodsSpecifications(info);
    logic.state.goodsNum = info['quantity'];
    logic.state.ec_shop_num_id = info["ec_shop_num_id"].toString(); //店铺编码
    logic.state.cart_id = info["cart_id"].toString(); //店铺编码
    logic.state.item_num_id = info["item_num_id"].toString(); //商品编码
    selectProduct(context, info);
  }

  void _reduce(cartId, cheaced, sum) {
    if (sum > 1) {
      sum--;
      logic.cartItemEdit(cartId, cheaced, sum);
      // controller.text = _sum.toString();
      // logic.update();
    }
    setState(() {});
  }

  @override
  void initState() {
    super.initState();
    var params1 = {
      'adv_category': '3',
      'page_num': 1,
      'page_size': 10,
      'status_num_id': 3
    };
    Api.getAdvertising(params1).listen((event) {
      if (event["code"] == 0 && event["list"] != null) {
        print('s行频列摆拍--- ${event["list"]}');
        setState(() {
          state.advertising = event['list'];
        });
      } else {
        setState(() {
          state.advertising = [];
        });
      }
    });

    getCurrentLocationInfo(success: (data) {
      var addressInfo = data['addressInfo'];
      var params = {
        "usr_num_id": SpUtil.getInt('empeNumId'),
        "use_platform": 2,
        "prv_num_id": addressInfo['prv_num_id'],
        "city_num_id": addressInfo['city_num_id'],
        "city_area_num_id": addressInfo['city_area_num_id'],
        "town_num_id": addressInfo['town_num_id'],
        "maplocation_x": addressInfo['maplocation_x'],
        "maplocation_y": addressInfo['maplocation_y'],
        'access_token': SpUtil.getString('token'),
      };
      logic.cartGoodsData(params);
    });
    setState(() {
      state.edit = false;
    });
    logic.getrecommendGoods();

    /// Can be set preset time. This case is "00:01.23".
    // _stopWatchTimerDown.setPresetTime(mSec: 1234);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: YPNavigationBar(
        '购物车',
        backgroundColor: EsColors.White,
        showBack: state.showBack ?? false,
        titleColor: EsColors.TitleSecondary,
        actions: [
          TextButton(
            onPressed: () {},
            child: TextButton(
              onPressed: () {
                setState(() {
                  state.edit = !state.edit;
                });
              },
              child: Text(
                state.edit ? '完成' : '编辑',
                style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.MD,
                    fontWeight: EsFontWeights.Normal),
              ),
            ),
          )
        ],
      ),
      body: GetBuilder<TrolleyLogic>(builder: (logic) {
        return Stack(
          children: [
            Padding(
              padding: const EdgeInsets.only(bottom: 55),
              child: CustomScrollView(
                slivers: <Widget>[
                  SliverToBoxAdapter(
                    child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                          state.advertising.length > 0
                              ? Container(
                                  margin:
                                      EdgeInsets.only(right: 20.w, left: 20.w),
                                  child: Column(
                                    children: _newList(state.advertising, 1),
                                  ),
                                )
                              : Container(),
                          // _tips('全网满减', '购满168元立减20元', EsColors.Primary,
                          //     EsColors.Primary.withOpacity(0.2)),
                          state.cartDataList != null &&
                                  state.cartDataList.length > 0
                              ? _list()
                              : _gwcnull(),
                          // Container(
                          //   width: MediaQuery.of(context).size.width,
                          //   color: Color(0xffffffff),
                          //   child: ListView.builder(
                          //     itemCount: state.advertising.length,
                          //     shrinkWrap: true,
                          //     physics: NeverScrollableScrollPhysics(),
                          //     itemBuilder: (ctx, index) {
                          //       return _getAdvertising(
                          //           index, state.advertising[index]);
                          //     },
                          //   ),
                          // ),
                          _expireGoodsList(),
                          _guessLickTitle(),
                          _guessLick()
                        ]),
                  )
                ],
              ),
            ),
            Positioned(bottom: 0, left: 0, right: 0, child: _bottom())
          ],
        );
      }),
      backgroundColor: EsColors.White,
    );
  }

  /// 满减tips
  Widget _tips(String tips, String info, Color tipsColor, Color bgColor,
      {bool visible = true, double left = 10}) {
    return Visibility(
      visible: visible,
      child: Container(
          color: bgColor,
          padding: EdgeInsets.fromLTRB(left, 12, 10, 12),
          child: Row(
            children: [
              Container(
                  padding: const EdgeInsets.fromLTRB(4, 1, 4, 2),
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    color: tipsColor,
                    borderRadius: BorderRadius.circular(10),
                  ),
                  child: Text(
                    tips,
                    style: TextStyle(
                        color: EsColors.White,
                        fontSize: EsSizes.XXS,
                        fontWeight: EsFontWeights.Normal),
                  )),
              SizedBox(width: 4),
              Expanded(
                child: Text(
                  info,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                      color: EsColors.TitleSecondary,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal),
                ),
              )
            ],
          )),
    );
  }

  /// 满减tips
  Widget _tipsBtn(String tips, String info, Color tipsColor, Color bgColor,
      {double left = 10, Function onTip, String tipBtnText = ''}) {
    return Container(
        color: bgColor,
        padding: EdgeInsets.fromLTRB(left, 12, 10, 12),
        child: Row(
          children: [
            Container(
                padding: const EdgeInsets.fromLTRB(4, 1, 4, 2),
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  color: tipsColor,
                  borderRadius: BorderRadius.circular(10),
                ),
                child: Text(
                  tips,
                  style: TextStyle(
                      color: EsColors.White,
                      fontSize: EsSizes.XXS,
                      fontWeight: EsFontWeights.Normal),
                )),
            SizedBox(width: 4),
            Expanded(
              child: Text(
                info,
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: EsColors.ContentSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal),
              ),
            ),
            InkWell(
              onTap: onTip,
              child: Text(
                tipBtnText,
                style: TextStyle(
                    color: tipsColor ?? EsColors.Primary, fontSize: 13),
              ),
            ),
          ],
        ));
  }

  /// 商品list
  Widget _list() {
    return Column(
      children: [
        for (int i = 0; i < state.cartDataList.length; i++)
          Column(
            children: [
              ShopName('${state.cartDataList[i]['ec_shop_name']}'),
              YpLine(),
              ListView.separated(
                  shrinkWrap: true,
                  physics: NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) => _goods(
                      state.cartDataList[i]['cart_item_list'][index], index),
                  separatorBuilder: (context, index) => YpLine(),
                  itemCount: state.cartDataList[i]['cart_item_list']?.length),
              YpLine(thickness: 20, height: 20, color: Color(0xffededed)),
            ],
          )

        // _shopList()
      ],
    );
  }

  /// 商品信息item
  Widget _goods(Map info, int index) {
    final List giftList = info['item_promotion_list'].length > 0
        ? info['item_promotion_list'][0]['gift_list'] ?? []
        : [];
    List promotionList = [];
    info['item_promotion_list'].forEach((item) {
      if (item['grade'] != 1) promotionList.add(item);
    });
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        // Visibility(
        //   visible: info['item_promotion_list'] != null &&
        //       info['item_promotion_list'].length > 0 &&
        //       logic.state.promotion_cat['tag_name_type'] == 1,
        //   child: _tips(
        //       "${info['item_promotion_list'].length > 0 ? info['item_promotion_list'][0]["corner_with_param"] : ''}",
        //       info['item_promotion_list'].length > 0
        //           ? '${info['item_promotion_list'][0]["corner_detail"]}'
        //           : '',
        //       EsColors.Primary,
        //       EsColors.White,
        //       visible: logic.state.promotion_cat != null &&
        //           logic.state.promotion_cat['tag_name_type'] == 1),
        // ),
        // 1130暂不上线该功能 隐藏
        ...List.generate(
          promotionList.length,
          (index) => promotionList != null && promotionList.length > 0
              ? _tipsBtn(
                  "${logic.state.promotion_cat['tag_name_type'] == 0 ? promotionList[index]["corner_with_no_param"] : promotionList[index]["corner_with_param"]}",
                  '${promotionList[index]["corner_detail"]}',
                  EsColors.Primary,
                  EsColors.White,
                  onTip: () {
                    // if (promotionList[0]['type_num_id'] == 6 &&
                    //     promotionList[0]['grade'] == 8 &&
                    //     promotionList[0]['match'] == true) return;
                    Get.toNamed(
                        promotionList[0]['type_num_id'] == 6 &&
                                promotionList[0]['grade'] == 8 &&
                                promotionList[0]['match'] == true
                            ? RouteConfig.goExchange
                            : RouteConfig.goCollect,
                        arguments: {
                          'reservedNo': promotionList[0]['reserved_no'],
                          'cornerDetail': promotionList[0]['corner_detail']
                        }).then((value) {
                      Get.offAllNamed(RouteConfig.main,
                          arguments: {'shoppingCart': '2'});
                    });
                  },
                  tipBtnText: promotionList[0]['type_num_id'] == 6 &&
                          promotionList[0]['grade'] == 8 &&
                          promotionList[0]['match'] == true
                      ? '去换购'
                      : '去凑单',
                  // tipBtnText: promotionList[0]['type_num_id'] == 6 &&
                  //         promotionList[0]['grade'] == 8 &&
                  //         promotionList[0]['match'] == true
                  //     ? ''
                  //     : '去凑单',
                )
              : SizedBox(),
        ),
        // YpLine(indent: 8),
        Padding(
          padding: const EdgeInsets.only(left: 8.0),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              SizedBox(width: 5),
              Expanded(
                child: Column(
                  children: [
                    for (var k = 0; k < info['items'].length; k++)
                      Column(
                        children: [
                          _goodsInfo(context, index, info['items'][k],
                              info['item_promotion_list']),
                          YpLine(indent: 58.w),
                          // _integral(),
                          // YpLine(indent: 58.w),
                          if (info['items'][k]['activity_type'] == 2 ||
                              info['items'][k]['activity_type'] == -2)
                            // ? _gift(info['items'][k])
                            // : Container()
                            _gift(info['items'][k])
                        ],
                      ),
                    for (var k = 0; k < giftList.length; k++)
                      Column(
                        children: [
                          _goodsInfo(context, index, giftList[k],
                              info['item_promotion_list'],
                              isPurchase: true),
                          YpLine(indent: 58.w),
                          // _integral(),
                          // YpLine(indent: 58.w),
                          // giftList[k]['is_part_integral'] != 0
                          //     ? _gift(info['items'][k])
                          //     : Container()
                          if (info['items'][k]['activity_type'] == 2 ||
                              info['items'][k]['activity_type'] == -2)
                            _gift(info['items'][k])
                        ],
                      ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }

  Widget _gwcnull() {
    return Container(
      child: Column(
        children: [
          Center(
            child: Image.asset(
              'assets/images/gwcem.png',
              width: setWidth(300),
              height: setWidth(300),
              fit: BoxFit.cover,
            ),
          ),
          SizedBox(
            height: 50.w,
          ),
          GestureDetector(
            onTap: () {
              final MainState state = Get.find<MainLogic>().state;
              state.selectedIndex.value = 0;
              state.pageController.jumpToPage(0);
            },
            child: Center(
              child: Container(
                padding: EdgeInsets.only(left: 20.w, right: 20.w),
                decoration: new BoxDecoration(
                    border: new Border.all(color: Colors.orange, width: 1),
                    borderRadius: new BorderRadius.circular((20.0))),
                child: Text(
                  '去购物',
                  style: TextStyle(color: Colors.orange),
                ),
              ),
            ),
          ),
          SizedBox(
            height: 50.w,
          )
        ],
      ),
    );
  }

  /// 主商品信息
  Widget _goodsInfo(
    context,
    int index,
    Map info,
    List promotionList, {
    bool isPurchase = false,
  }) {
    List gifts = [];
    if (promotionList.length > 0) {
      if (promotionList[0]["gifts"] != null) {
        gifts = promotionList[0]["gifts"]["gift_groups"][0]["gift_items"];
      }
    }
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            GestureDetector(
              onTap: () {
                var _sum = info['quantity'].toInt();
                var cartId = info['cart_id'];
                var cheaced = info['is_checked'];
                if (cheaced == 1) {
                  cheaced = 0;
                } else {
                  cheaced = 1;
                }
                logic.cartItemEdit(cartId, cheaced, _sum);
                // logic.cartGoodsData();
                logic.update();
                // setState(() {
                //   isSelect = !isSelect;
                // });
                // print(isSelect ? '选中' : '取消');
              },
              child: Image(
                image: AssetImage(info['is_checked'] == 1
                    ? 'assets/images/selectIcon1.png'
                    : 'assets/images/select1.png'),
                width: 48.w,
              ),
            ),
            SizedBox(width: 5),
            GestureDetector(
              onTap: () {
                Get.toNamed(RouteConfig.goodsDetail, arguments: {
                  'itemNumId': info['item_num_id'].toString(),
                  'styleNumId': info['style_num_id'].toString(),
                  // 'shopId': SpUtil.getInt('storeShopNum').toString(),
                  'shopId': info['ec_shop_num_id'].toString(),
                  'ecStyleNumId': info['ec_style_num_id'].toString(),
                  'typeIndex': info['is_pre_sale'] ?? 0
                }).then((value) {
                  getCurrentLocationInfo(success: (data) {
                    var addressInfo = data['addressInfo'];
                    var params = {
                      "usr_num_id": SpUtil.getInt('empeNumId'),
                      "use_platform": 2,
                      "prv_num_id": addressInfo['prv_num_id'],
                      "city_num_id": addressInfo['city_num_id'],
                      "city_area_num_id": addressInfo['city_area_num_id'],
                      "town_num_id": addressInfo['town_num_id'],
                      "maplocation_x": addressInfo['maplocation_x'],
                      "maplocation_y": addressInfo['maplocation_y'],
                      'access_token': SpUtil.getString('token'),
                    };
                    logic.cartGoodsData(params);
                  });
                });
              },
              child: CachedImage(
                  width: 80,
                  height: 80,
                  margin: EdgeInsets.fromLTRB(0, 10, 8, 12),
                  scale: BoxFit.cover,
                  path: info['image_default_id']),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  GestureDetector(
                    onTap: () {
                      Get.toNamed(RouteConfig.goodsDetail, arguments: {
                        'itemNumId': info['item_num_id'].toString(),
                        'styleNumId': info['style_num_id'].toString(),
                        // 'shopId': SpUtil.getInt('storeShopNum').toString(),
                        'shopId': info['ec_shop_num_id'].toString(),
                        'ecStyleNumId': info['ec_style_num_id'].toString(),
                        'typeIndex': info['is_pre_sale'] ?? 0
                      }).then((value) {
                        // toast("back");
                        getCurrentLocationInfo(success: (data) {
                          var addressInfo = data['addressInfo'];
                          var params = {
                            "usr_num_id": SpUtil.getInt('empeNumId'),
                            "use_platform": 2,
                            "prv_num_id": addressInfo['prv_num_id'],
                            "city_num_id": addressInfo['city_num_id'],
                            "city_area_num_id": addressInfo['city_area_num_id'],
                            "town_num_id": addressInfo['town_num_id'],
                            "maplocation_x": addressInfo['maplocation_x'],
                            "maplocation_y": addressInfo['maplocation_y'],
                            'access_token': SpUtil.getString('token'),
                          };
                          logic.cartGoodsData(params);
                        });
                      });
                    },
                    child: Text(
                      info['title'],
                      style: TextStyle(
                          color: EsColors.TitleSecondary,
                          fontSize: EsSizes.MD,
                          fontWeight: EsFontWeights.Normal),
                      maxLines: 1,
                    ),
                  ),
                  isPurchase
                      ? Padding(
                          padding: const EdgeInsets.only(top: 2),
                          child: Text(
                            '加价购',
                            style: TextStyle(fontSize: 12),
                          ),
                        )
                      : SizedBox(),
                  info["nospec"] == 1
                      ? Container(
                          // height: 35.w,
                          )
                      : GestureDetector(
                          onTap: () {
                            print('选择其他规格');
                            guige(info);
                            //YpBottomSheet.showSpecification(context, state.specificationList, (selectIndex, selectString, {info}) {
                            //   print(info);
                            // });
                          },
                          behavior: HitTestBehavior.opaque,
                          child: Container(
                            padding: const EdgeInsets.symmetric(
                                vertical: 1, horizontal: 6),
                            margin: const EdgeInsets.fromLTRB(0, 6, 0, 8),
                            constraints: BoxConstraints(
                                maxWidth:
                                    MediaQuery.of(context).size.width / 3),
                            decoration: BoxDecoration(
                              border: Border.all(
                                color: Color(0xFFDDDDDD),
                                width: 1,
                              ),
                              borderRadius: BorderRadius.circular(10),
                            ),
                            child: Row(
                              children: [
                                Expanded(
                                  child: Text(
                                    info["spec_info"],
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis,
                                    style: TextStyle(
                                        color: EsColors.Content,
                                        fontSize: EsSizes.XXS,
                                        fontWeight: EsFontWeights.Normal),
                                  ),
                                ),
                                Icon(
                                  Icons.expand_more,
                                  size: 14,
                                  color: EsColors.Content,
                                )
                              ],
                            ),
                          ),
                        ),
                  if (info['item_single_promotion_list'] != null &&
                      info['item_single_promotion_list'].length > 0)
                    Container(
                      padding:
                          EdgeInsets.symmetric(horizontal: 15.w, vertical: 6.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(logic.state.angle[0]),
                            topRight: Radius.circular(logic.state.angle[1]),
                            bottomLeft: Radius.circular(logic.state.angle[2]),
                            bottomRight: Radius.circular(logic.state.angle[3])),
                        border: Border.all(
                          color: getColorFromHex(
                              logic.state.promotion_cat['frame_color']),
                          width: 1.w,
                        ),
                        color: getColorFromHex(
                            logic.state.promotion_cat['tag_fgcolor']),
                      ),
                      child: Text(
                        // tag_name_type ==1 45 0 一口价
                        logic.state.promotion_cat != null
                            ? logic.state.promotion_cat['tag_name_type'] == 1
                                ? "${info['item_single_promotion_list'][0]["corner_with_param"]}"
                                : "${info['item_single_promotion_list'][0]["corner_with_no_param"]}"
                            : '',
                        style: TextStyle(
                          color: getColorFromHex(
                              logic.state.promotion_cat['word_color']),
                          fontSize: 26.sp,
                          height: 1.3,
                        ),
                      ),
                    ),
                  if (info['is_seckill'] == 1)
                    Container(
                      height: setWidth(26),
                      padding: EdgeInsets.symmetric(horizontal: setWidth(4)),
                      margin: EdgeInsets.only(top: 10.w),
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(setWidth(4)),
                        border: Border.all(
                          width: setWidth(1),
                          color: Colors.red,
                        ),
                      ),
                      child: Text(
                        "秒杀",
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          color: Colors.red,
                          fontSize: 18.sp,
                          height: 1.3,
                        ),
                      ),
                    ),
                  Row(
                    children: [
                      Expanded(
                        child: RichText(
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          text: TextSpan(
                              text: '￥',
                              style: TextStyle(
                                  fontSize: EsSizes.XXS,
                                  color: EsColors.Primary,
                                  fontWeight: EsFontWeights.Normal),
                              children: <TextSpan>[
                                TextSpan(
                                    text: info['price'].toStringAsFixed(2),
                                    style: TextStyle(
                                        fontSize: EsSizes.LG,
                                        color: EsColors.Primary,
                                        fontWeight: EsFontWeights.Medium)),
                              ]),
                        ),
                      ),
                      IconButton(
                          onPressed: () {
                            //hxh
                            var _sum = info['quantity'].toInt();
                            if (_sum > 1) {
                              _sum--;
                              var cartId = info['cart_id'];
                              var cheaced = info['is_checked'];

                              logic.cartItemEdit(cartId, cheaced, _sum);
                              // logic.cartGoodsData();
                              logic.update();
                              print('sub');
                            } else {
                              showDialog(
                                  context: context,
                                  barrierDismissible: false,
                                  builder: (BuildContext context) {
                                    return AlertDialog(
                                      title: Text('提示'),
                                      content: Text('是否删除商品'),
                                      actions: <Widget>[
                                        FlatButton(
                                          onPressed: () =>
                                              Navigator.of(context).pop(),
                                          child: Text('取消'),
                                        ),
                                        FlatButton(
                                          onPressed: () {
                                            Navigator.of(context).pop();
                                            var params = {
                                              "usr_num_id": state
                                                  .orderMemberData["empeNumId"],
                                              'access_token':
                                                  SpUtil.getString('token'),
                                              "use_platform": 2,
                                              "cart_id": info['cart_id']
                                            };
                                            logic.cartDelete(params);
                                          },
                                          textColor: Colors.red,
                                          child: Text('确定'),
                                        ),
                                      ],
                                    );
                                  });
                            }
                          },
                          icon: Image(
                            image: AssetImage("assets/images/reduce.png"),
                            width: 48.w,
                          )),
                      Text(info['quantity'].toStringAsFixed(0),
                          style: TextStyle(
                              fontSize: EsSizes.LG,
                              color: EsColors.TitleSecondary,
                              fontWeight: EsFontWeights.Normal)),
                      IconButton(
                        onPressed: () {
                          var _sum = info['quantity'].toInt();
                          _sum++;
                          var cartId = info['cart_id'];
                          var cheaced = info['is_checked'];
                          logic.cartItemEdit(cartId, cheaced, _sum);
                          // logic.cartGoodsData();
                          logic.update();

                          print('add');
                        },
                        icon: Image(
                          image: AssetImage("assets/images/plus.png"),
                          width: 48.w,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
        if (gifts.length > 0)
          Container(
            // color: Colors.red,
            padding: EdgeInsets.only(bottom: 30.w),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("赠品"),
                SizedBox(width: 30.w),
                Container(
                  width: 600.w,
                  child: Column(
                    children: gifts
                        .map((e) => Text(
                              "${e["title"]} x${e["qty"]}",
                              // maxLines: 1,
                              // overflow: TextOverflow.ellipsis,
                            ))
                        .toList(),
                  ),
                ),
              ],
            ),
          ),
        if (info['is_seckill'] == 1)
          Text(
            "秒杀:${info['seckill_desc']}",
            style: TextStyle(
              fontSize: 26.sp,
            ),
          ),
        if (info['is_seckill'] == 1) SizedBox(height: 10),
      ],
    );
  }

  /// 猜你喜欢
  Widget _guessLickTitle() {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 30),
      child: Row(
        children: [
          Expanded(child: YpLine()),
          Container(
            width: 5,
            height: 5,
            decoration: BoxDecoration(
              color: EsColors.BackGround,
              borderRadius: BorderRadius.circular(10),
            ),
          ),
          SizedBox(width: 10),
          Text('猜你喜欢',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: EsColors.TitleSecondary,
                  fontSize: EsSizes.LG,
                  fontWeight: EsFontWeights.Medium)),
          SizedBox(width: 10),
          Container(
            width: 5,
            height: 5,
            decoration: BoxDecoration(
              color: EsColors.BackGround,
              borderRadius: BorderRadius.circular(10),
            ),
          ),
          Expanded(child: YpLine()),
        ],
      ),
    );
  }

  /// 猜你喜欢
  /// 猜你喜欢
  Widget _guessLick() {
    return Padding(
      padding: EdgeInsets.only(
          left: 12,
          right: 12,
          top: 20,
          bottom: MediaQuery.of(context).padding.bottom + 10),
      child: Wrap(
        spacing: 10,
        runSpacing: 10,
        children: List.generate(
            state.TJlist.length,
            (index) => GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    print('点击猜你喜欢的商品详情');
                    // if (state.TJlist[index]['style_store'] > 0) {
                    Get.toNamed(RouteConfig.goodsDetail, arguments: {
                      'itemNumId':
                          state.TJlist[index]['default_item_num_id'].toString(),
                      'styleNumId':
                          state.TJlist[index]['style_num_id'].toString(),
                      // 'shopId': SpUtil.getInt('storeShopNum').toString(),
                      'shopId': state.TJlist[index]['shop_num_id'].toString(),
                      'ecStyleNumId':
                          state.TJlist[index]['ec_style_num_id'].toString(),
                      'typeIndex': state.TJlist[index]['is_pre_sale'] ?? 0
                    });
                    // }
                  },
                  child: Container(
                    decoration: EsDecoration.BoxShadowDefault,
                    width: MediaQuery.of(context).size.width / 2 - 18,
                    padding:
                        const EdgeInsets.only(left: 12, right: 12, bottom: 16),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Stack(
                          children: [
                            CachedImage(
                              path: state.TJlist[index]['image_default_id'],
                              width: MediaQuery.of(context).size.width / 2 - 24,
                              height:
                                  MediaQuery.of(context).size.width / 2 - 24,
                            ),
                            Positioned(
                              left: setWidth(97),
                              top: setWidth(106),
                              child: state.TJlist[index]['style_store'] <= 0
                                  ? Container(
                                      width: setWidth(120),
                                      height: setWidth(120),
                                      alignment: Alignment.center,
                                      decoration: BoxDecoration(
                                        color:
                                            Color(0xffbbbbbb).withOpacity(0.7),
                                        borderRadius:
                                            BorderRadius.circular(setWidth(60)),
                                      ),
                                      child: Text(
                                        '售罄',
                                        style: TextStyle(
                                          color: Colors.white,
                                          fontSize: 15,
                                        ),
                                      ),
                                    )
                                  : SizedBox(),
                            ),
                          ],
                        ),
                        Text(state.TJlist[index]['title'],
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                color: EsColors.TitleSecondary,
                                fontSize: EsSizes.MD,
                                fontWeight: EsFontWeights.Normal)),
                        state.TJlist[index]['norm_tag_models'] != null &&
                                state.TJlist[index]['norm_tag_models'].length >
                                    0
                            ? Container(
                                padding: EdgeInsets.all(5.w),
                                decoration: BoxDecoration(
                                  border: new Border.all(
                                      width: 1, color: Colors.orange[300]),
                                  color: Colors.orange[100],
                                  //设置圆角
                                  borderRadius:
                                      BorderRadius.all(Radius.circular(4.0.w)),
                                ),
                                child: Text(
                                  state.TJlist[index]['norm_tag_models'][0]
                                              ['tag_name'] !=
                                          null
                                      ? state.TJlist[index]['norm_tag_models']
                                          [0]['tag_name']
                                      : '',
                                  style: TextStyle(
                                      fontSize: 20.sp,
                                      color: Colors.orange[600]),
                                ),
                              )
                            : Container(),
                        SizedBox(height: 16),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            RichText(
                              maxLines: 1,
                              overflow: TextOverflow.ellipsis,
                              text: TextSpan(
                                  text: logic.getMoney(state.TJlist[index])[0],
                                  style: TextStyle(
                                      fontSize: EsSizes.LG,
                                      color: EsColors.Primary,
                                      fontWeight: EsFontWeights.Medium),
                                  children: <TextSpan>[
                                    TextSpan(
                                        text: logic
                                            .getMoney(state.TJlist[index])[1],
                                        style: TextStyle(
                                            decoration:
                                                TextDecoration.lineThrough,
                                            fontSize: EsSizes.XS,
                                            color: EsColors.ContentSecondary,
                                            fontWeight: EsFontWeights.Medium)),
                                  ]),
                            ),
                            if (state.TJlist[index]['fresh_type'] != 8)
                              GestureDetector(
                                onTap: () {
                                  if (state.TJlist[index]['style_store'] > 0) {
                                    logic.bottomaddShoppingCart(
                                        ec_shop_num_id: state.TJlist[index]
                                                ['shop_num_id']
                                            .toString(),
                                        item_num_id: state.TJlist[index]
                                                ['default_item_num_id']
                                            .toString(),
                                        style_num_id: state.TJlist[index]
                                                ['style_num_id']
                                            .toString(),
                                        ec_style_num_id: state.TJlist[index]
                                                ['ec_style_num_id']
                                            .toString());
                                  }
                                },
                                child: Image.asset(
                                  'assets/images/shoppingCart_image.png',
                                  width: setWidth(50),
                                  color: state.TJlist[index]['style_store'] > 0
                                      ? Color(0xffEA5504)
                                      : Color(0xffcccccc),
                                  height: setWidth(50),
                                  fit: BoxFit.cover,
                                ),
                              ),
                          ],
                        ),
                      ],
                    ),
                  ),
                )),
      ),
    );
  }

  /// 积分
  // Widget _integral() {
  //   return Padding(
  //     padding: EdgeInsets.only(left: 58.w),
  //     child: Row(
  //       children: [
  //         Text('积分优惠', style: TextStyle(fontSize: EsSizes.XS, color: EsColors.TitleSecondary, fontWeight: EsFontWeights.Medium)),
  //         Expanded(child: Text('  使用20积分可享用20积分可享用20积分可享受优惠价29.9元', maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: EsSizes.XS, color: EsColors.TitleSecondary, fontWeight: EsFontWeights.Normal))),
  //         Text('积分不足', style: TextStyle(fontSize: EsSizes.XS, color: EsColors.Pink, fontWeight: EsFontWeights.Normal)),
  //         TextButton(
  //             style: TextButton.styleFrom(minimumSize: Size(32, 22), padding: EdgeInsets.zero),
  //             onPressed: () {
  //               print('参加');
  //             },
  //             child: Text(
  //               '参加',
  //               style: TextStyle(fontSize: EsSizes.XS, color: Colors.orange, fontWeight: EsFontWeights.Normal),
  //             ))
  //       ],
  //     ),
  //   );
  // }

  /// 赠品信息
  Widget _gift(Map more) {
    return
        // ? _tips('赠品', '原装】方太JCD1/JCD6/JCD9适配3D免清洁滤油网', Colors.orange, EsColors.White, left: 58.w)
        Padding(
      padding: EdgeInsets.only(top: 10, bottom: 10, right: 12, left: 58.w),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Text(
            '积分优惠',
            style: TextStyle(
                color: EsColors.TitleSecondary,
                fontSize: EsSizes.XS,
                fontWeight: EsFontWeights.Medium),
          ),
          SizedBox(width: 6),
          Expanded(
            child: ListView.builder(
                shrinkWrap: true,
                physics: NeverScrollableScrollPhysics(),
                itemCount: 1,
                itemBuilder: (context, index) {
                  return Row(
                    children: [
                      Expanded(
                        child: Text(
                          more['integral_exchange_desc'] != null
                              ? more['integral_exchange_desc']
                              : '',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                              color: EsColors.TitleSecondary,
                              fontSize: EsSizes.XS,
                              fontWeight: EsFontWeights.Normal),
                        ),
                      ),
                      SizedBox(width: 4),
                      if (more['activity_type'] == -2)
                        Text(
                          '积分不足',
                          maxLines: 1,
                          style: TextStyle(
                              color: Colors.orange,
                              fontSize: EsSizes.XS,
                              fontWeight: EsFontWeights.Normal),
                        ),
                      if (more['activity_type'] == 2)
                        GestureDetector(
                          child: Text(
                            more['is_part_integral'] == 1 ? '取消' : '参加',
                            maxLines: 1,
                            style: TextStyle(
                                color: Colors.orange,
                                fontSize: EsSizes.XS,
                                fontWeight: EsFontWeights.Normal),
                          ),
                          onTap: () {
                            getCurrentLocationInfo(success: (data) {
                              var addressInfo = data['addressInfo'];
                              var params;
                              if (more['is_part_integral'] == 1) {
                                params = {
                                  "usr_num_id": SpUtil.getInt('empeNumId'),
                                  "use_platform": 2,
                                  "mode": 'cart',
                                  'shop_id': more['ec_shop_num_id'],
                                  "prv_num_id": addressInfo['prv_num_id'],
                                  "city_num_id": addressInfo['city_num_id'],
                                  "city_area_num_id":
                                      addressInfo['city_area_num_id'],
                                  "town_num_id": addressInfo['town_num_id'],
                                  "maplocation_x": addressInfo['maplocation_x'],
                                  "maplocation_y": addressInfo['maplocation_y'],
                                  'access_token': SpUtil.getString('token'),
                                  // 'integral_item': [more['item_num_id']],
                                  'integral_item_list': [more['item_num_id']],
                                  'integral_type': 2,
                                  // 'is_part_integral': 0
                                };

                                print('aaas');
                                print(params);
                              } else {
                                params = {
                                  "usr_num_id": SpUtil.getInt('empeNumId'),
                                  "use_platform": 2,
                                  "mode": 'cart',
                                  'shop_id': more['ec_shop_num_id'],
                                  "prv_num_id": addressInfo['prv_num_id'],
                                  "city_num_id": addressInfo['city_num_id'],
                                  "city_area_num_id":
                                      addressInfo['city_area_num_id'],
                                  "town_num_id": addressInfo['town_num_id'],
                                  "maplocation_x": addressInfo['maplocation_x'],
                                  "maplocation_y": addressInfo['maplocation_y'],
                                  'access_token': SpUtil.getString('token'),
                                  // 'integral_item': [more['item_num_id']],
                                  'integral_item_list': [more['item_num_id']],
                                  'integral_type': 1,
                                  // 'is_part_integral': 1
                                };
                              }
                              logic.cartGoodsData(params);
                            });
                          },
                        )
                    ],
                  );
                }),
          )
        ],
      ),
    );
  }

  /// 失效商品部分
  Widget _expireGoodsList() {
    return Visibility(
      visible: state.sxGoodList?.isNotEmpty ?? false,
      child: Column(children: [
        // ShopName('失效商品', showIcon: false),
        YpLine(),
        ListView.separated(
            shrinkWrap: true,
            physics: NeverScrollableScrollPhysics(),
            itemBuilder: (context, index) => _expireGoods(index),
            separatorBuilder: (context, index) => YpLine(indent: 48),
            itemCount: state.sxGoodList?.length),
        YpLine(indent: 48),
        OutlinedButton(
            onPressed: () {
              showDialog(
                  context: context,
                  barrierDismissible: false,
                  builder: (BuildContext context) {
                    return AlertDialog(
                      title: Text('提示'),
                      content: Text('是否删除失效商品'),
                      actions: <Widget>[
                        FlatButton(
                          onPressed: () => Navigator.of(context).pop(),
                          child: Text('取消'),
                        ),
                        FlatButton(
                          onPressed: () {
                            Navigator.of(context).pop();
                            logic.clearsxArr();
                          },
                          textColor: Colors.red,
                          child: Text('确定'),
                        ),
                      ],
                    );
                  });
            },
            style: OutlinedButton.styleFrom(
              backgroundColor: EsColors.White,
              padding: EdgeInsets.zero,
              minimumSize: Size(88, 24),
              shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(12)),
              side: BorderSide(color: EsColors.BackGround, width: 1),
            ),
            child: Text(
              '清空失效商品',
              style: TextStyle(
                  color: EsColors.Content,
                  fontSize: EsSizes.XS,
                  fontWeight: EsFontWeights.Normal),
            )),
        SizedBox(height: 15),
      ]),
    );
  }

  /// 失效商品item
  Widget _expireGoods(int index) {
    return Stack(children: [
      Padding(
        padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
                padding: const EdgeInsets.fromLTRB(4, 1, 4, 2),
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  color: EsColors.TitleSecondary,
                  borderRadius: BorderRadius.circular(10),
                ),
                child: Text(
                  '售馨',
                  style: TextStyle(
                      color: EsColors.White,
                      fontSize: EsSizes.XXS,
                      fontWeight: EsFontWeights.Normal),
                )),
            SizedBox(width: 8),
            CachedImage(
                width: 80,
                height: 80,
                margin: EdgeInsets.fromLTRB(0, 10, 8, 12),
                scale: BoxFit.cover,
                path: state.sxGoodList[index]['image_default_id']),
            SizedBox(width: 8),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  Text(
                    state.sxGoodList[index]['title'],
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: EsColors.TitleSecondary,
                        fontSize: EsSizes.MD,
                        fontWeight: EsFontWeights.Normal),
                  ),
                  Text(
                    state.sxGoodList[index]['title'] == null
                        ? ''
                        : state.sxGoodList[index]['title'],
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    style: TextStyle(
                        color: EsColors.TitleSecondary,
                        fontSize: EsSizes.SM,
                        fontWeight: EsFontWeights.Normal),
                  ),
                  Padding(
                    padding: const EdgeInsets.only(top: 18),
                    child: RichText(
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      text: TextSpan(
                          text: '￥',
                          style: TextStyle(
                              fontSize: EsSizes.XXS,
                              color: EsColors.TitleSecondary,
                              fontWeight: EsFontWeights.Normal),
                          children: <TextSpan>[
                            TextSpan(
                                text:
                                    state.sxGoodList[index]['price'].toString(),
                                style: TextStyle(
                                    fontSize: EsSizes.LG,
                                    color: EsColors.TitleSecondary,
                                    fontWeight: EsFontWeights.Medium)),
                          ]),
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      ),
      Positioned(
          left: 0,
          right: 0,
          top: 0,
          bottom: 0,
          child: DecoratedBox(
            decoration: BoxDecoration(color: EsColors.White.withOpacity(0.8)),
          ))
    ]);
  }

  //显示底部弹框的功能
  selectProduct(BuildContext context, Map info) {
    var asum = info['quantity'];
    var amoney = info['price'];
    //用于在底部打开弹框的效果
    showModalBottomSheet(
        isScrollControlled: true,
        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10.0.w),
        ),
        builder: (BuildContext context) {
          //构建弹框中的内容
          return StatefulBuilder(builder: (context, setDialogState) {
            return Container(
              height: 1000.w,
              width: 750.w,
              // decoration: BoxDecoration(
              //   borderRadius: BorderRadius.only(topLeft: Radius.circular(30.w),topRight: Radius.circular(30.w),),
              // ),
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.symmetric(vertical: 20.w),
                    margin: EdgeInsets.only(right: 22.w, left: 22.w),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      border: Border(
                        bottom: BorderSide(
                          color: Color(0xfff0f0f0),
                        ),
                      ),
                    ),
                    child: GetBuilder<TrolleyLogic>(builder: (logic) {
                      return Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          CachedImage(
                            path: logic.state.goodsSpecificationsImageData,
                            width: 180.w,
                            height: 180.w,
                          ),
                          SizedBox(
                            width: 10.w,
                          ),
                          Expanded(
                            child: Text(
                              logic.state.goodsSpecificationsTitleData,
                              style: TextStyle(
                                color: Color(0xff222222),
                                fontSize: 28.sp,
                              ),
                              maxLines: 2,
                              textAlign: TextAlign.start,
                              overflow: TextOverflow.ellipsis,
                            ),
                          )
                        ],
                      );
                    }),
                  ),
                  Expanded(
                    child: Container(
                      padding: EdgeInsets.symmetric(vertical: 20.w),
                      margin: EdgeInsets.only(right: 22.w, left: 22.w),
                      width: 710.w,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        border: Border(
                          bottom: BorderSide(
                            color: Color(0xfff0f0f0),
                          ),
                        ),
                      ),
                      child: SingleChildScrollView(
                        child: GetBuilder<TrolleyLogic>(
                          builder: (logic) {
                            var data =
                                logic.state.goodsSpecificationsData['specs'];
                            int len = 0;
                            if (data != null && data['specs'] != null) {
                              len = data['specs'].length;
                            }

                            return ListView.builder(
                              itemBuilder: (ctx, index) {
                                //商品规格列表
                                var data1 =
                                    logic.state.goodsSpecificationsData['specs']
                                        ['specs'][index];
                                //商品规格对应数据
                                var data2 = logic
                                    .state.goodsSpecificationsData['spec_item'];
                                List data1List = data1["spec_values"];
                                return SpecificationsWidget(
                                  data: data,
                                  data1: data1,
                                  data2: data2,
                                  data1List: data1List,
                                  index: index,
                                  logic: logic,
                                );
                              },
                              itemCount: len,
                              shrinkWrap: true,
                              physics: NeverScrollableScrollPhysics(),
                            );
                          },
                        ),
                      ),
                    ),
                  ),
                  Container(
                      color: Colors.white,
                      padding: EdgeInsets.symmetric(
                        vertical: 30.w,
                        horizontal: 46.w,
                      ),
                      child: SingleChildScrollView(
                          child: GetBuilder<TrolleyLogic>(builder: (logic) {
                        return Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                Visibility(
                                  child: RichText(
                                    text: TextSpan(
                                      children: [
                                        TextSpan(
                                          text:
                                              "￥${logic.state.sumParic.toStringAsFixed(2)}",
                                          style: TextStyle(
                                              color: Config.mainColor,
                                              fontSize: 40.w),
                                        ),
                                      ],
                                    ),
                                  ),
                                  visible: logic.state.sumParic != null &&
                                      logic.state.goodsNum != null,
                                ),
                                Container(
                                  child: Row(
                                    children: [
                                      GestureDetector(
                                        onTap: () {
                                          if (asum > 1) {
                                            setDialogState(() {
                                              // 在此处做数据的重新赋值，dialog算新页面，setstate的页面刷新没有影响到showModalBottomSheet出的页面
                                              asum--;
                                            });

                                            // controller.text = _sum.toString();
                                            // logic.update();
                                          }
                                          // _reduce(info['cart_id'], info['is_checked'], info['quantity']);
                                        },
                                        child: Image(
                                          image: AssetImage(
                                              "assets/images/reduce.png"),
                                          width: 44.w,
                                        ),
                                      ),
                                      SizedBox(
                                        width: 15.w,
                                      ),
                                      Text(
                                        asum.toStringAsFixed(0),
                                        style: TextStyle(
                                          fontSize: 36.w,
                                          color: Color(0xff333333),
                                        ),
                                      ),
                                      SizedBox(
                                        width: 15.w,
                                      ),
                                      GestureDetector(
                                        onTap: () {
                                          setDialogState(() {
                                            // 在此处做数据的重新赋值，dialog算新页面，setstate的页面刷新没有影响到showModalBottomSheet出的页面
                                            asum++;
                                          });

                                          // _plus(info['cart_id'], info['is_checked'], info['quantity']);
                                        },
                                        child: Image(
                                          image: AssetImage(
                                              "assets/images/plus.png"),
                                          width: 44.w,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 50.w,
                            ),
                            GestureDetector(
                              onTap: () async {
                                //代客下单该规格先删除商品然后重新增加
                                logic.specCart(asum);
                                //重新增加
                              },
                              child: ButtonWidget(title: "确定"),
                            ),
                          ],
                        );
                      }))),
                ],
              ),
            );
          });
        },
        context: context);
  }

  /// 结算部分
  Widget _bottom() {
    bool disabled = state.cartData['total_price'] != null &&
        state.cartData['begin_delivery_price'] >
            state.cartData['total_price'] &&
        !state.edit;
    return Container(
      decoration: EsDecoration.BoxShadowDefault,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Expanded(
            child: Padding(
              padding: const EdgeInsets.only(bottom: 10),
              child: Row(
                children: [
                  GestureDetector(
                    onTap: () {
                      var params = {
                        "usr_num_id": SpUtil.getInt('empeNumId'),
                        // "emp_num_id": SpUtil.getInt('empeNumId'),
                        "use_platform": 1,
                        "type": state.cartData["checkedall"] == 0
                            ? 'cancel'
                            : "checked",
                        // "inv_from_type":
                        //     state.sendType == 1 ? 3 : 2,
                        'access_token': SpUtil.getString('token'),
                      };
                      print('购物车全选');
                      logic.cartChoose(params);
                    },
                    child: Row(
                      children: [
                        Padding(
                          padding: const EdgeInsets.only(left: 8),
                          child: Image(
                            image: AssetImage(state.cartData["checkedall"] == 0
                                ? 'assets/images/selectIcon1.png'
                                : 'assets/images/select1.png'),
                            width: 48.w,
                          ),
                        ),
                        Text(
                          '全选',
                          style: TextStyle(
                              color: EsColors.Content,
                              fontWeight: EsFontWeights.Normal,
                              fontSize: EsSizes.MD),
                        )
                      ],
                    ),
                  ),
                  Expanded(child: SizedBox()),
                  Visibility(
                    visible: !state.edit,
                    child: Text(
                      '不含运费',
                      style: TextStyle(
                          fontSize: EsSizes.XS,
                          color: EsColors.ContentSecondary,
                          fontWeight: EsFontWeights.Normal),
                    ),
                  ),
                  SizedBox(width: 4),
                  Visibility(
                    visible: !state.edit,
                    child: RichText(
                      // textAlign: TextAlign.center,
                      maxLines: 1,
                      overflow: TextOverflow.ellipsis,
                      text: TextSpan(
                          text: '共',
                          style: TextStyle(
                              fontSize: EsSizes.MD,
                              color: EsColors.TitleSecondary,
                              fontWeight: EsFontWeights.Normal),
                          children: <TextSpan>[
                            TextSpan(
                                text: '￥',
                                style: TextStyle(
                                    fontSize: EsSizes.SM,
                                    color: EsColors.Primary,
                                    fontWeight: EsFontWeights.Normal)),
                            TextSpan(
                                text:
                                    "${state.cartData['total_price'] ?? '加载中'}",
                                style: TextStyle(
                                    fontSize: EsSizes.LG,
                                    color: EsColors.Primary,
                                    fontWeight: EsFontWeights.Medium)),
                          ]),
                    ),
                  ),
                  SizedBox(width: 4),
                ],
              ),
            ),
          ),
          SizedBox(width: 4),
          TextButton(
            style: disabled
                ? ButtonStyle(
                    minimumSize: MaterialStateProperty.all(Size(100, 55)),
                    shape: MaterialStateProperty.all(RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(0),
                    )),
                    overlayColor: MaterialStateProperty.all(Colors.transparent),
                    backgroundColor: MaterialStateProperty.resolveWith(
                        (states) => EsColors.Fill),
                  )
                : TextButton.styleFrom(
                    minimumSize: Size(100, 55),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(0)),
                    ),
                    backgroundColor: EsColors.Primary,
                  ),
            onPressed: () {
              print('结算');
              if (state.edit) {
                showDialog(
                    context: context,
                    barrierDismissible: false,
                    builder: (BuildContext context) {
                      return AlertDialog(
                        title: Text('提示'),
                        content: Text('是否删除商品'),
                        actions: <Widget>[
                          FlatButton(
                            onPressed: () => Navigator.of(context).pop(),
                            child: Text('取消'),
                          ),
                          FlatButton(
                            onPressed: () {
                              Navigator.of(context).pop();
                              logic.allDed();
                            },
                            textColor: Colors.red,
                            child: Text('确定'),
                          ),
                        ],
                      );
                    });
              } else if (!disabled) {
                if (state.clickNum > 100) {
                  toast('商品总件数超过100上限,请减少数量后结算');
                  return;
                }
                if (state.clickNum <= 0) {
                  toast('请选择至少一件商品');
                  return;
                }
                Get.toNamed(RouteConfig.settleAccounts).then((value) {
                  getCurrentLocationInfo(success: (data) {
                    var addressInfo = data['addressInfo'];
                    var params = {
                      "usr_num_id": SpUtil.getInt('empeNumId'),
                      "use_platform": 2,
                      "prv_num_id": addressInfo['prv_num_id'],
                      "city_num_id": addressInfo['city_num_id'],
                      "city_area_num_id": addressInfo['city_area_num_id'],
                      "town_num_id": addressInfo['town_num_id'],
                      "maplocation_x": addressInfo['maplocation_x'],
                      "maplocation_y": addressInfo['maplocation_y'],
                      'access_token': SpUtil.getString('token'),
                    };
                    logic.cartGoodsData(params);
                  });
                  setState(() {
                    state.edit = false;
                  });
                });
              }
            },
            child: Text(
              state.edit
                  ? '删除'
                  : disabled
                      ? '满${toConstraintLen(state.cartData['begin_delivery_price'] ?? 0, 3)}\n配送'
                      : '结算(${state.clickNum})',
              textAlign: TextAlign.center,
              style: TextStyle(
                  fontSize: EsSizes.LG,
                  color: EsColors.White,
                  fontWeight: EsFontWeights.Normal),
            ),
          )
        ],
      ),
    );
  }

  Widget _getDate(start, end) {
    var startTime = start.split(" ")[0];
    var endTime = end.split(" ")[0];
    return Container(
      // width: 300.w,
      margin: EdgeInsets.only(bottom: 10.0),
      child: Text(
        '有效期 $startTime -- $endTime',
        style: TextStyle(
          color: Color(0xff333333),
        ),
      ),
    );
  }

//  优惠券类型
  Widget _couponType(String typeIndex) {
    var type = '折扣券';
    if (typeIndex == '0') {
      type = '折扣券';
    } else if (typeIndex == '1') {
      type = '现金券';
    } else if (typeIndex == '2') {
      type = '免邮券';
    } else if (typeIndex == '8') {
      type = '兑换券';
    }

    return Container(
      child: Text(
        type,
        style: TextStyle(
          color: Color(0xffa5673f),
          fontSize: 16,
          fontWeight: FontWeight.bold,
        ),
      ),
    );
  }

  List<Widget> _newList(dynamic adList, int index) {
    var commonWidgets = List<Widget>();
    for (var item in adList) {
      if (item['adv_type'] == '1' && item['adv_line_num'] == index) {
        commonWidgets.add(
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                new Image(
                  width: 750.r,
                  height: 375.r,
                  fit: BoxFit.fill,
                  image: new NetworkImage(
                    item['adv_object_url'],
                  ),
                ),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(10),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        );
      } else if (item['adv_type'] == '2' && item['adv_line_num'] == index) {
        commonWidgets.add(
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                new VideoPlayerPlus(
                  VideoPlayerController.network(item['adv_object_url']),
                ),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            // color: Color(0xff708090),
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(30),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        );
      } else if (item['adv_type'] == '3' && item['adv_line_num'] == index) {
        Map<String, dynamic> user = jsonDecode(item['style_num_name']);
        user.forEach((key, value) {
          value[0]['shop_num_id'] = key;
          item['mdms_style'] = value[0];
        });
        commonWidgets.add(
          InkWell(
            onTap: () {
              String itemNumId =
                  item['mdms_style']['default_item_num_id'].toString();
              String styleNumId = item['mdms_style']['style_num_id'].toString();
              String ecStyleNumId =
                  item['mdms_style']['ec_style_num_id'].toString();
              Get.toNamed(RouteConfig.goodsDetail, arguments: {
                'itemNumId': itemNumId,
                'styleNumId': styleNumId,
                'shopId': item['mdms_style']['shop_num_id'],
                'ecStyleNumId': ecStyleNumId,
                'typeIndex': item['mdms_style']['is_pre_sale'] ?? 0,
              });
            },
            child: Container(
              margin: EdgeInsets.only(bottom: 20.w),
              padding: EdgeInsets.only(
                  left: 30.w, right: 30.w, top: 25.w, bottom: 15.w),
              decoration: BoxDecoration(
                  boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 5.0.w)],
                  color: Colors.white,
                  borderRadius: new BorderRadius.circular((20.0.w))),
              child: Column(
                children: [
                  // Container(
                  //   alignment: Alignment.centerLeft,
                  //   margin: EdgeInsets.only(right: 10.w, bottom: 30.w),
                  //   child: Text(
                  //     item['mdms_style']['title'],
                  //     style: TextStyle(
                  //       color: Color(0xff333333),
                  //       fontWeight: FontWeight.bold,
                  //       fontSize: 32.w,
                  //     ),
                  //   ),
                  // ),
                  Container(
                    constraints: BoxConstraints(minHeight: 250.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          // width: 300.w,
                          child: Image.network(
                            item['mdms_style']['image_default_id'],
                            width: 250.w,
                            height: 220.w,
                            fit: BoxFit.cover,
                          ),
                        ),
                        Expanded(
                          child: Container(
                            margin: EdgeInsets.only(left: 30.w),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Container(
                                  alignment: Alignment.centerLeft,
                                  child: Text(
                                    item['mdms_style']['style_num_name'],
                                    style: TextStyle(
                                      color: Color(0xff666666),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 30.w,
                                    ),
                                  ),
                                ),
                                Stack(
                                  children: [
                                    item['tag_name'] != null
                                        ? Positioned(
                                            //方法二
                                            right: 0,
                                            bottom: 0,
                                            child: new Container(
                                              padding: EdgeInsets.only(
                                                left: 6.0,
                                                right: 6.0,
                                                top: 2.0,
                                                bottom: 2.0,
                                              ),
                                              decoration: BoxDecoration(
                                                // color: Color(0xff708090),
                                                border: Border.all(
                                                  width: 1,
                                                  color: Color(0xff708090),
                                                ),
                                                borderRadius: BorderRadius.all(
                                                  Radius.circular(30),
                                                ),
                                              ),
                                              child: Text(
                                                item['tag_name'],
                                                style: TextStyle(
                                                  color: Color(0xff708090),
                                                  fontSize: 10,
                                                ),
                                              ),
                                            ),
                                          )
                                        : Container(),
                                    Container(
                                      alignment: Alignment.centerLeft,
                                      margin: EdgeInsets.only(top: 80.w),
                                      child: Text(
                                        '¥ ${item['mdms_style']['price']}',
                                        style: TextStyle(
                                          color: Color(0xff666666),
                                          fontWeight: FontWeight.bold,
                                          fontSize: 30.w,
                                        ),
                                      ),
                                    ),
                                  ],
                                )
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      } else if (item['adv_type'] == '4' && item['adv_line_num'] == index) {
        commonWidgets.add(InkWell(
          onTap: () {
            // 拼团
            if (item['results'][0]['ecactivity_classify'] == 1) {
              Map<String, dynamic> map = {
                'icon_name': item['activity_num_name'],
                'activity_num_id': item['activity_num_id'],
                'pic_url': '',
                'linktype': 9,
                'linktarget': null,
                'shop_id': item['results'][0]['ec_shop_num_id']
              };
              Get.toNamed(
                RouteConfig.collage,
                arguments: {'model': map},
              );
            } else if (item['results'][0]['ecactivity_classify'] == 2) {
              // 限时秒杀
              Map<String, dynamic> map = {'results': item['results']};
              Get.toNamed(
                RouteConfig.seckillHome,
                parameters: {},
                arguments: {'model': map},
              );
            } else if (item['results'][0]['ecactivity_classify'] == 3) {
              // 预售
              Map<String, dynamic> map = {
                'icon_name': item['activity_num_name'],
                'pic_url': '',
                'linktype': 12,
                'linktarget': item['results'][0]['ecactivity_id'],
                'shop_id': item['results'][0]['ec_shop_num_id'],
              };
              Get.toNamed(
                RouteConfig.preSaleActive,
                arguments: {'model': map},
              );
            } else {
              Map<String, dynamic> map = {
                'icon_name': item['activity_num_name'],
                'activity_num_id': item['activity_num_id'],
                'pic_url': '',
                'linktype': 9,
                'linktarget': null
              };
              Get.toNamed(
                RouteConfig.collage,
                arguments: {'model': map},
              );
            }
          },
          child: Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                item['adv_object_url'] != null
                    ? new Image(
                        width: 750.r,
                        height: 375.r,
                        fit: BoxFit.fill,
                        image: new NetworkImage(
                          item['adv_object_url'],
                        ),
                      )
                    : Container(),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(10),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        ));
      } else if (item['adv_type'] == '2' && item['adv_line_num'] == index) {
        commonWidgets.add(
          Container(
            margin: EdgeInsets.only(bottom: 20.w),
            child: Stack(
              children: <Widget>[
                new VideoPlayerPlus(
                  VideoPlayerController.network(item['adv_object_url']),
                ),
                item['tag_name'] != null
                    ? Positioned(
                        //方法二
                        right: 20.w,
                        bottom: 20.w,
                        child: new Container(
                          padding: EdgeInsets.only(
                            left: 6.0,
                            right: 6.0,
                            top: 2.0,
                            bottom: 2.0,
                          ),
                          decoration: BoxDecoration(
                            // color: Color(0xff708090),
                            border: Border.all(
                              width: 1,
                              color: Color(0xff708090),
                            ),
                            borderRadius: BorderRadius.all(
                              Radius.circular(30),
                            ),
                          ),
                          child: Text(
                            item['tag_name'],
                            style: TextStyle(
                              color: Color(0xff708090),
                              fontSize: 10,
                            ),
                          ),
                        ),
                      )
                    : Container(),
              ],
            ),
          ),
        );
      } else if (item['adv_type'] == '3' && item['adv_line_num'] == index) {
        Map<String, dynamic> user = jsonDecode(item['style_num_name']);
        user.forEach((key, value) {
          value[0]['shop_num_id'] = key;
          item['mdms_style'] = value[0];
        });
        commonWidgets.add(
          InkWell(
            onTap: () {
              String itemNumId =
                  item['mdms_style']['default_item_num_id'].toString();
              String styleNumId = item['mdms_style']['style_num_id'].toString();
              String ecStyleNumId =
                  item['mdms_style']['ec_style_num_id'].toString();
              Get.toNamed(RouteConfig.goodsDetail, arguments: {
                'itemNumId': itemNumId,
                'styleNumId': styleNumId,
                'shopId': item['mdms_style']['shop_num_id'],
                'ecStyleNumId': ecStyleNumId,
                'typeIndex': item['mdms_style']['is_pre_sale'] ?? 0,
              });
            },
            child: Container(
              margin: EdgeInsets.only(bottom: 20.w),
              padding: EdgeInsets.only(
                  left: 30.w, right: 30.w, top: 25.w, bottom: 15.w),
              decoration: BoxDecoration(
                  boxShadow: [BoxShadow(color: Colors.grey, blurRadius: 5.0.w)],
                  color: Colors.white,
                  borderRadius: new BorderRadius.circular((20.0.w))),
              child: Column(
                children: [
                  // Container(
                  //   alignment: Alignment.centerLeft,
                  //   margin: EdgeInsets.only(right: 10.w, bottom: 30.w),
                  //   child: Text(
                  //     item['mdms_style']['title'],
                  //     style: TextStyle(
                  //       color: Color(0xff333333),
                  //       fontWeight: FontWeight.bold,
                  //       fontSize: 32.w,
                  //     ),
                  //   ),
                  // ),
                  Container(
                    constraints: BoxConstraints(minHeight: 250.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          // width: 300.w,
                          child: Image.network(
                            item['mdms_style']['image_default_id'],
                            width: 250.w,
                            height: 220.w,
                            fit: BoxFit.cover,
                          ),
                        ),
                        Expanded(
                          child: Container(
                            margin: EdgeInsets.only(left: 30.w),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Container(
                                  alignment: Alignment.centerLeft,
                                  child: Text(
                                    item['mdms_style']['style_num_name'],
                                    style: TextStyle(
                                      color: Color(0xff666666),
                                      fontWeight: FontWeight.bold,
                                      fontSize: 30.w,
                                    ),
                                  ),
                                ),
                                Stack(
                                  children: [
                                    item['tag_name'] != null
                                        ? Positioned(
                                            //方法二
                                            right: 0,
                                            bottom: 0,
                                            child: new Container(
                                              padding: EdgeInsets.only(
                                                left: 6.0,
                                                right: 6.0,
                                                top: 2.0,
                                                bottom: 2.0,
                                              ),
                                              decoration: BoxDecoration(
                                                // color: Color(0xff708090),
                                                border: Border.all(
                                                  width: 1,
                                                  color: Color(0xff708090),
                                                ),
                                                borderRadius: BorderRadius.all(
                                                  Radius.circular(30),
                                                ),
                                              ),
                                              child: Text(
                                                item['tag_name'],
                                                style: TextStyle(
                                                  color: Color(0xff708090),
                                                  fontSize: 10,
                                                ),
                                              ),
                                            ),
                                          )
                                        : Container(),
                                    Container(
                                      alignment: Alignment.centerLeft,
                                      margin: EdgeInsets.only(top: 80.w),
                                      child: Text(
                                        '¥ ${item['mdms_style']['price']}',
                                        style: TextStyle(
                                          color: Color(0xff666666),
                                          fontWeight: FontWeight.bold,
                                          fontSize: 30.w,
                                        ),
                                      ),
                                    ),
                                  ],
                                )
                              ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ),
        );
      } else if (item['adv_type'] == '4' && item['adv_line_num'] == index) {
        commonWidgets.add(
          InkWell(
            onTap: () {
              // 拼团
              if (item['results'][0]['ecactivity_classify'] == 1) {
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'pic_url': '',
                  'linktype': 9,
                  'linktarget': null,
                  'shop_id': item['results'][0]['ec_shop_num_id']
                };
                Get.toNamed(
                  RouteConfig.collage,
                  arguments: {'model': map},
                );
              } else if (item['results'][0]['ecactivity_classify'] == 2) {
                // 限时秒杀
                Map<String, dynamic> map = {'results': item['results']};
                Get.toNamed(
                  RouteConfig.seckillHome,
                  parameters: {},
                  arguments: {'model': map},
                );
              } else if (item['results'][0]['ecactivity_classify'] == 3) {
                // 预售
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'pic_url': '',
                  'linktype': 12,
                  'linktarget': item['results'][0]['ecactivity_id'],
                  'shop_id': item['results'][0]['ec_shop_num_id'],
                };
                Get.toNamed(
                  RouteConfig.preSaleActive,
                  arguments: {'model': map},
                );
              } else {
                Map<String, dynamic> map = {
                  'icon_name': item['activity_num_name'],
                  'pic_url': '',
                  'linktype': 9,
                  'linktarget': null
                };
                Get.toNamed(
                  RouteConfig.collage,
                  arguments: {'model': map},
                );
              }
            },
            child: Container(
              margin: EdgeInsets.only(bottom: 20.w),
              child: Stack(
                children: <Widget>[
                  item['results'].length != 0
                      ? new Image(
                          image: new NetworkImage(
                            item['activity_cover_url'],
                          ),
                        )
                      : Container(),
                  item['tag_name'] != null && item['results'].length != 0
                      ? Positioned(
                          //方法二
                          right: 20.w,
                          bottom: 20.w,
                          child: new Container(
                            padding: EdgeInsets.only(
                              left: 6.0,
                              right: 6.0,
                              top: 2.0,
                              bottom: 2.0,
                            ),
                            decoration: BoxDecoration(
                              border: Border.all(
                                width: 1,
                                color: Color(0xff708090),
                              ),
                              borderRadius: BorderRadius.all(
                                Radius.circular(30),
                              ),
                            ),
                            child: Text(
                              item['tag_name'],
                              style: TextStyle(
                                color: Color(0xff708090),
                                fontSize: 10,
                              ),
                            ),
                          ),
                        )
                      : Container(),
                ],
              ),
            ),
          ),
        );
      } else if (item['adv_type'] == '5' && item['adv_line_num'] == index) {
        var data = jsonDecode(item['coupon_num_name']);
        commonWidgets.add(
          Container(
            child: ListView.builder(
              physics: NeverScrollableScrollPhysics(),
              shrinkWrap: true,
              itemExtent: 160.0,
              itemCount: data.length,
              itemBuilder: (ctx, index) {
                return InkWell(
                  enableFeedback: false,
                  onTap: data[index]['cover_url'] == null
                      ? () {}
                      : () {
                          toast('领取中...');
                          var params = {
                            "use_platform": 2,
                            "coupon_num_id":
                                data[index]['series'].toString(), //券编码
                            "usr_num_id": SpUtil.getInt('empeNumId'),
                            "access_token": SpUtil.getString('token'),
                            "relation": "领券中心",
                            "qsource": 301,
                            "relation_indate": "永久有效",
                            "user_num_id": SpUtil.getInt('empeNumId'),
                          };
                          Api.getCoupon(params).listen(
                            (event) {
                              toastDismissOther(event['message']);
                            },
                          );
                        },
                  child: Container(
                    constraints: new BoxConstraints.expand(
                      height: 134.0,
                    ),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(4.0),
                      image: DecorationImage(
                        image: NetworkImage("${data[index]['cover_url']}"),
                        fit: BoxFit.cover,
                      ),
                      color: Color(0xfff2c899),
                    ),
                    margin: EdgeInsets.only(bottom: 20.w, top: 20.w),
                    child: Row(
                      children: data[index]['cover_url'] != null
                          ? []
                          : [
                              Container(
                                width: 100.0,
                                margin: EdgeInsets.only(right: 20.w),
                                padding: EdgeInsets.only(left: 20.w),
                                child: Column(
                                  children: [
                                    Container(
                                      height: 30,
                                    ),
                                    data[index]['coupontype'] == '0'
                                        ? Row(
                                            children: [
                                              Text(
                                                '${data[index]['face_value'] / 10}',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                  fontSize: 36.0,
                                                ),
                                              ),
                                              Text(
                                                '折',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                ),
                                              ),
                                            ],
                                          )
                                        : Row(
                                            children: [
                                              Text(
                                                '¥',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                ),
                                              ),
                                              Text(
                                                '${data[index]['face_value']}',
                                                style: TextStyle(
                                                  color: Color(0xffa5673f),
                                                  fontSize: 36.0,
                                                ),
                                              ),
                                            ],
                                          ),
                                    Container(
                                      margin: EdgeInsets.only(top: 4.0),
                                      child: _couponType(
                                          data[index]['coupontype']),
                                    ),
                                  ],
                                ),
                              ),
                              Expanded(
                                child: Stack(
                                  children: [
                                    item['tag_name'] != null
                                        ? Positioned(
                                            //方法二
                                            right: 20.w,
                                            bottom: 20.w,
                                            child: new Container(
                                              padding: EdgeInsets.only(
                                                left: 6.0,
                                                right: 6.0,
                                                top: 2.0,
                                                bottom: 2.0,
                                              ),
                                              decoration: BoxDecoration(
                                                border: Border.all(
                                                  width: 1,
                                                  color: Color(0xff708090),
                                                ),
                                                borderRadius: BorderRadius.all(
                                                  Radius.circular(10),
                                                ),
                                              ),
                                              child: Text(
                                                item['tag_name'],
                                                style: TextStyle(
                                                  color: Color(0xff708090),
                                                  fontSize: 10,
                                                ),
                                              ),
                                            ),
                                          )
                                        : Container(),
                                    Container(
                                      // width: 400.w,
                                      child: Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.start,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.start,
                                        children: [
                                          Container(
                                            margin:
                                                EdgeInsets.only(bottom: 10.0),
                                            padding: EdgeInsets.only(top: 18.w),
                                            child: Text(
                                              data[index]['title'],
                                              style: TextStyle(
                                                color: Color(0xff000000),
                                                fontSize: 18.0,
                                              ),
                                            ),
                                          ),
                                          Container(
                                            child: item['start_time'] != null &&
                                                    item['end_time'] != null
                                                ? _getDate(item['start_time'],
                                                    item['end_time'])
                                                : Container(),
                                          ),
                                          InkWell(
                                            onTap: () {
                                              toast('领取中...');
                                              var params = {
                                                "use_platform": 2,
                                                "coupon_num_id": data[index]
                                                        ['series']
                                                    .toString(), //券编码
                                                "usr_num_id":
                                                    SpUtil.getInt('empeNumId'),
                                                "access_token":
                                                    SpUtil.getString('token'),
                                                "relation": "领券中心",
                                                "qsource": 301,
                                                "relation_indate": "永久有效",
                                                "user_num_id":
                                                    SpUtil.getInt('empeNumId'),
                                              };
                                              Api.getCoupon(params).listen(
                                                (event) {
                                                  toastDismissOther(
                                                      event['message']);
                                                },
                                              );
                                            },
                                            child: Container(
                                              padding: EdgeInsets.only(
                                                left: 10.0,
                                                right: 10.0,
                                                top: 4.0,
                                                bottom: 8.0,
                                              ),
                                              margin:
                                                  EdgeInsets.only(bottom: 20.w),
                                              decoration: BoxDecoration(
                                                color: Color(0xffa5673f),
                                                borderRadius:
                                                    BorderRadius.circular(20.0),
                                              ),
                                              child: Text(
                                                '立即领取',
                                                style: TextStyle(
                                                  color: Color(0xffffffff),
                                                  fontSize: 16,
                                                ),
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                    ),
                  ),
                );
              },
            ),
          ),
        );
      }
    }
    return commonWidgets;
  }

  @override
  bool get wantKeepAlive => true;
}
